# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=netcat-openbsd
_pkgver=1.226-1.1
pkgver=${_pkgver/-/.}
pkgrel=0
pkgdesc="The TCP/IP swiss army knife. OpenBSD variant from debian."
url="https://packages.debian.org/sid/netcat-openbsd"
arch="all"
license="BSD-3-Clause"
makedepends="libbsd-dev"
subpackages="$pkgname-doc"
options="!check"
source="https://salsa.debian.org/debian/netcat-openbsd/-/archive/debian/$_pkgver/netcat-openbsd-debian-$_pkgver.tar.gz
	b64.patch
	base64.c
	"
builddir="$srcdir/netcat-openbsd-debian-$_pkgver"

prepare() {
	default_prepare

	# debian keeps their patchset in their own folder
	while read -r patch; do
		patch -Np1 < debian/patches/"$patch"
	done < debian/patches/series

	# linux port requires b64_ntop
	cp "$srcdir"/base64.c .
	sed -i Makefile -e "/SRCS=/s;\(.*\);& base64.c;"
}

build() {
	make CFLAGS="$CFLAGS -DDEBIAN_VERSION=\"\\\"$_pkgver\\\"\""
}

package() {
	install -Dm755 nc "$pkgdir"/usr/bin/nc
	install -Dm644 nc.1 "$pkgdir"/usr/share/man/man1/nc.openbsd.1
}

sha512sums="
3a7aef24555d007b108f4b628d9d5f3f4490a8c2312395926b6e35f204cce55fcaefa06c62b9e3a931a4eb6b2008892a3764f91fd8eb59b44327a16ac80d8619  netcat-openbsd-debian-1.226-1.1.tar.gz
c35ed4e10d0a8d312d8e730cafb8c69538183ce4af5a3cd2a1ceabfc58e009a23bf487507ef4aab5ad0617abf1dde6ac4be4dff6aac4bbb8091f2089cb6a8fe3  b64.patch
2d4b117397e6882b0f4357bb11ca1f520746c59e0305a58f8651582a9cff17f4c59cacb14ce93de1d0fe78db5ba7fd9096c0176afc61b2c715b0b9a0444c2b4f  base64.c
"
